package yang;
import java.time.Duration;
import java.time.ZonedDateTime;

public class PhoneBillingCalculator {

    public double calculateCost(ZonedDateTime start, ZonedDateTime end) {
        if (start.isAfter(end)) {
            throw new IllegalArgumentException("End time must be after start time");
        }

        long durationSeconds = Duration.between(start.toInstant(), end.toInstant()).getSeconds();
        long durationMinutes = (long) Math.ceil(durationSeconds / 60.0);
        durationMinutes = Math.max(1, durationMinutes); // 确保至少1分钟

        if (durationMinutes <= 20) {
            return durationMinutes * 0.05;
        } else {
            return 1.00 + (durationMinutes - 20) * 0.10;
        }
    }
}